#!/usr/bin/env perl

# Copyright (C) 2018 Itoh Laboratory, Tokyo Institute of Technology
# 
# This file is part of GINGER.
# 
# GINGER is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# 
# GINGER is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License along
# with GINGER; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

use strict;
use warnings;
use Carp;

my $baseDir  = $ARGV[0];
my $oPrefix  = $ARGV[1];
my $mWeight  = $ARGV[2] || 1.6; # MAPPING_WEIGHT  (1.6)
my $dWeight  = $ARGV[3] || 1.4; # DENOVO_WEIGHT   (1.4)
my $hWeight  = $ARGV[4] || 2.0; # HOMOLOGY_WEIGHT (2.0)
my $aWeight  = $ARGV[5] || 1.8; # AUGUSTUS_WEIGHT (1.8)
my $sWeight  = $ARGV[6] || 1.2; # SNAP_WEIGHT     (1.2)

my $mappingGtf     = "$baseDir/Prep/mapping/mapping/$oPrefix.gtf";
my $mappingToMerge = "$baseDir/Prep/mapping/merge/$oPrefix\_merge.gff3";
my $gmapResult     = "$baseDir/Prep/denovo/$oPrefix\_denovo.cd.fasta.gmap.filtered";
my $denovoResult   = "$baseDir/Prep/denovo/$oPrefix\_final.gff3";
my $homologyResult = "$baseDir/Prep/homology/homology_filter/all_homology_filter.gff";
my $augustusResult = "$baseDir/Prep/abinitio/augustus/Augustus_abinitio.gtf";
my $snapResult     = "$baseDir/Prep/abinitio/snap/$oPrefix.final.gff";

my $flag = 0;
foreach my $anInputFile ($mappingGtf, $mappingToMerge, $gmapResult, $denovoResult, $homologyResult, $augustusResult, $snapResult) {
    unless (-e $anInputFile) {
        print STDERR "No input file \"$anInputFile\".\n";
        $flag = 1;
    }
}
if ($flag == 1) {
    die "Not enough input files.";
}

# file path
print "MAPPING_GTF=$mappingGtf\n";
print "MAPPING_TO_MERGE=$mappingToMerge\n";
print "GMAP_RESULT=$gmapResult\n";
print "DENOVO_RESULT=$denovoResult\n";
print "HOMOLOGY_RESULT=$homologyResult\n";
print "AUGUSTUS_RESULT=$augustusResult\n";
print "SNAP_RESULT=$snapResult\n";

# weight
printf("MAPPING_WEIGHT=%f\n",  $mWeight);
printf("DENOVO_WEIGHT=%f\n",   $dWeight);
printf("HOMOLOGY_WEIGHT=%f\n", $hWeight);
printf("AUGUSTUS_WEIGHT=%f\n", $aWeight);
printf("SNAP_WEIGHT=%f\n",     $sWeight);



